# -*- coding:utf-8 -*-
__author__ = 'weikai'
from request_cicc.interface.login import login
from Scheduler.insert_session import get_session
from Scheduler.session import getSession
from request_getdata import *
from CicRenewalBody import  *
from  request_cic.utils import getlatedate

#车牌号获取续保用户信息入口
def cic_entrance_renwal(requestcic,CPlateNo):
    try:
        dts=renewal_data(requestcic,CPlateNo=CPlateNo)
        if dts!=0:
            jq_plyNo=getLastPlyByVhl(requestcic,CPlyNo=dts['CPlyNo'])
            dts['jq_plyNo']=jq_plyNo
            dts['sy_plyNo']=CPlyNo=dts['CPlyNo']
            user=get_insurance_info(requestcic,dts)
            #user['endDate']=dts['TInsrncEndTm'].split(" ")[0] #保险结束时间
            #修改问题  2017-03-09 ：中华联合返回的数据为 日期 23:59:59  加一天为启保时间
            user['endDate']=getlatedate(1, str_date=dts['TInsrncEndTm'].split(" ")[0])
            user["COMPANY_ID"]="4"
            return user
        else:
            return 0
    except Exception as e:
        return 0
        print(e)

if __name__=="__main__":
    base64strdt=get_session(['4','5'])
    if len(base64strdt)!=0:
        sessiondt=getSession(base64strdt)
        requestcic=sessiondt['4']
        loginRes=sessiondt['5']
    else:
        requestcic=logincic()
        loginRes=login()
    licenseNoList = ["苏AW6A58","苏AY9B65","苏AY0D88","苏AR6G99","苏CW099J","苏AK0C77","苏AB2Q60","苏AB9N35","苏AB3Q98","苏AK8A77","苏AB0Q87","苏B768TD","苏ACT331"]
    for i in licenseNoList:
        #'苏ACT331'
        print json.dumps(cic_entrance_renwal(requestcic,i),ensure_ascii=False,indent=4)
